package classes.Commands
{
	import UIUtils.uif_util;
	
	import components.editor.c_baseElement;
	import components.editor.c_bitmapElement;
	
	import flash.display.BitmapData;
	
	public class c_applyBrush extends c_baseCommand {
		private var _backBmd	: BitmapData;
		private var _newBmd		: BitmapData;
		public function c_applyBrush(a_element: c_bitmapElement, a_newBmd: BitmapData, a_backBmd: BitmapData) {
			super(a_element);
			_newBmd = a_newBmd;
			_backBmd = a_backBmd;
		}
		
		protected function get bitmapElement(): c_bitmapElement {
			return element as c_bitmapElement;
		}
		
		override public function Execute():void {
			bitmapElement.bitmap.bitmapData.copyPixels(_newBmd, _newBmd.rect, uif_util.NULLPOINT);
		}
		
		override public function unExecute():void {
			bitmapElement.bitmap.bitmapData.copyPixels(_backBmd, _backBmd.rect, uif_util.NULLPOINT);
		}
		
		override public function dispose():void {
			super.dispose();
			_newBmd.dispose();
			_backBmd.dispose();
		}
	}
}